DBClass was created to help us avoid the tedium of creating Access data base classes for our VB5 applications. It creates the classes for us, containing all the requisite lets and gets as well as list/combo box fillers, navigation tags, and other database functions that one would wish to have encapsulated within classes. The Advanced table update feature allows programs to update only those fields that have been changed - which improves save time to tables containing many fields.
The default class assumes that your tables' first two fields are the ID field - an autonumber, and a text description field in that order. Your table should also contain an IsNew - YesNo - field. If you don't want your tables to have these fields, then simply change the Add function within the generated classes that you build. As a rule, text fields should allow nulls. The default class also comments-out the initial recordset creation in the Class_Initialize Sub. For small tables, you would want to un-comment this line, so that the class recordset is created upon initialization. In tables with many records, however, you may wish to delay the recordset creation until you can apply a Filter to the class which would reduce the resulting recordset when you call Requery (see Filling a form, below).
The class builder is shareware. The default class can be changed with the available source code. Constructive criticism is always welcome. You need to have VB5, SP3 on your PC already. If DBClass does not work, then try downloading the full install from www.nesolutions.com.
The zip includes:
dbclass.exe - the utility - if you have VB5, it should just work
dbclass.txt - this document
errorhandler.cls - a really basic error handler that must be placed with your project
propertyupdate.cls - a DBClass support class... add this and the errorhandler class along with any data classes created by DBClass to your project
DBClass should run from anywhere in your system. DBClass will create class files within the same directory as your Access mdb files, so you will probably have to move them. Again, if DBClass does not work on your system, then download the full installation mentioned above - keeping in mind that DBClass was created using VB5! Northeast Solutions (Dew Design, LLC) will not be held responsible for, well, anything. So there. Good luck and enjoy the extra time this utility gives you to spend with family and friends. The source code will allow you to customize DBClass to create classes for databases other than Access, using ADO, RDO, etc.
Sample code:
The sample code is for a form that adds a record first, then updates it.
Filling a form from the class (part of Procedure FillForm):
("private oList as New Names" has already been declared, where Names is a class based on the Names Table within my Access database)
With oList
.Filter = "WHERE Names.ID = " & CStr(iID) '-- Limit the class
.Requery '-- Reset the class' recordset
'-- Fill the form fields
txtName(0) = .lname
txtName(1) = .fname
txtName(2) = .address
txtName(3) = .city
txtName(4) = .state
txtName(5) = .zip
txtName(6) = .hphone
txtName(7) = .fax
txtName(8) = .ophone
txtName(9) = .ssno
txtName(10) = .notes
chkType(0) = Abs(.buyer)
chkType(1) = Abs(.seller)
chkType(2) = Abs(.agent)
chkType(3) = Abs(.lender)
chkType(4) = Abs(.professional)
chkType(5) = Abs(.office)
chkType(6) = Abs(.mail)
End With
Adding a new record:
Call oList.Add
Call FillForm(oList.ID)
txtName(0).SetFocus
Saving a record:
oList.isnew = False '-- See cancel code on why there should be an IsNew flag